package com.gurun.camera.device;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;

import com.danale.player.SPlayer;
import com.danale.player.entity.CloudRecordDevice;
import com.danale.player.entity.SdRecordDevice;
import com.danale.player.window.ScreenType;
import com.danale.sdk.platform.entity.v3.PushMsg;
import com.gurun.camera.R;
import com.gurun.camera.R2;
import com.gurun.camera.device.constant.VideoDataType;
import com.gurun.camera.device.presenter.ICloudAndSDPresenter;
import com.gurun.camera.device.presenter.impl.CloudAndSdPresenter;
import com.gurun.camera.device.presenter.impl.VideoPresenter;
import com.gurun.camera.device.view.ICloudSdPlayView;
import com.gurun.camera.utils.ToastUtil;

import butterknife.BindView;
import butterknife.ButterKnife;

public class RecordActivity extends BaseVideoActivity implements ICloudSdPlayView {

//    ICloudAndSDPresenter cloudAndSDPresenter;
//    VideoDataType dataType;
//    String device_id;
//    long timestamp;
//    PushMsg pushMsg;
//
//    @BindView(R2.id.back)
//    Button back;
//    @BindView(R2.id.title)
//    TextView title;
//    @BindView(R2.id.splayer)
//    SPlayer splayer;
//    @BindView(R2.id.capture)
//    Button capture;
//    @BindView(R2.id.record)
//    Button record;
//    @BindView(R2.id.audio)
//    Button audio;
//    @BindView(R2.id.talk)
//    Button talk;
//    @BindView(R2.id.cloud)
//    Button cloud;
//    @BindView(R2.id.disk)
//    Button disk;

    public static void startActivity(Context context, String device_id, VideoDataType dataType, PushMsg pushMsg) {
        Intent intent = new Intent();
        intent.putExtra("device_id", device_id);
        intent.putExtra("data_type", dataType);
        intent.putExtra("push_msg", pushMsg);
        intent.setClass(context, RecordActivity.class);
        context.startActivity(intent);
    }

    public static void startActivity(Context context, String id, VideoDataType dataType, long timestamp) {
        Intent intent = new Intent();
        intent.setClass(context, RecordActivity.class);
        intent.putExtra("device_id", id);
        intent.putExtra("data_type", dataType);
        intent.putExtra("timestamp", timestamp);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_video);
//        ButterKnife.bind(this);
//
//        initData();
//        initView();
//        resumeData();
    }

    private void initData() {
//        device_id = getIntent().getStringExtra("device_id");
//        dataType = (VideoDataType) getIntent().getSerializableExtra("data_type");
//        timestamp = getIntent().getLongExtra("timestamp", 0);
//        pushMsg = (PushMsg) getIntent().getSerializableExtra("push_msg");
//        videoPresenter = new VideoPresenter(this, dataType, splayer);
//        cloudAndSDPresenter = new CloudAndSdPresenter(this, dataType);
    }

    private void initView() {
//        talk.setVisibility(View.GONE);
//        cloud.setVisibility(View.GONE);
//        disk.setVisibility(View.GONE);
    }

    private void resumeData() {

//        WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
//        DisplayMetrics displayMetrics = new DisplayMetrics();
//        windowManager.getDefaultDisplay().getMetrics(displayMetrics);
//
//        videoPresenter.setData(device_id);
//        cloudAndSDPresenter.setData(device_id);
//        videoPresenter.initPlay(displayMetrics.widthPixels, (float) 16 / (float) 9, ScreenType.One);    //Set the aspect ratio
//        if (dataType == VideoDataType.CLOUD){
//            cloudAndSDPresenter.getCloudPlayerInfo(timestamp, 1);
//        } else if (dataType == VideoDataType.DISK){
//            cloudAndSDPresenter.getSDPlayerInfo(timestamp, 1);
//        } else if (dataType == VideoDataType.CLOUD_SINGLE){
//            cloudAndSDPresenter.getCloudPlayerInfoByPushMsg(pushMsg);
//        }
    }

    @Override
    public void handleCloudStartVideo(CloudRecordDevice device, int code) {
//        if (code == 0){
//            videoPresenter.setCloudPlayData(device);
//            videoPresenter.prepare();
//            videoPresenter.startVideo();
//        }else {
//            ToastUtil.showShortToast(mContext,getString(R.string.cloud_play_failure));
//        }
    }

    @Override
    public void handleSDStartVideo(SdRecordDevice device) {
//        videoPresenter.setSDRecordData(device);
//        videoPresenter.prepare();
//        videoPresenter.startVideo();
    }
}